#ifndef PHYSICMANAGER_H
#define PHYSICMANAGER_H

#include <Box2D.h>
//#include <SDL_gfxPrimitives.h>
#include <SDL_rotozoom.h>
#include "FrameListener.h"
#include "PhysicObject.h"
#include "Image.h"
#include <list>

class PhysicManager: public FrameListener
{
    public:
//    void Init(const SDL_Rect& worldSize);
//    void Init(int x1, int y1, int x2, int y2);
    static PhysicManager& GetInstance();
    static PhysicManager* GetInstancePtr();
        virtual ~PhysicManager();
    PhysicObject* CreateBox(Image* img, int posX = 0, int posY = 0, float density = 1.0f, float friction = 0.0f);
    void RemoveObject(PhysicObject* object);
    void SetLowerBounds(float x, float y);
    void SetUpperBounds(float x, float y);
    private:
    static PhysicManager mInstance;
    PhysicManager();


    b2AABB mWorldAABB;
    b2World *mWorld;
	b2Vec2 mGravity;

	float32 mTimeStep;
	int32 mIterations;

	bool FrameStarted(float timeSinceLastFrame);
	bool FrameEnded();

	std::list<PhysicObject*> ObjectList;
	std::list<PhysicObject*>::iterator ObjectListIterator;
};

#endif // PHYSICMANAGER_H
